﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QLThuVien
{
    class LoaiSach
    {
         string maloai, loai;
        public LoaiSach() { }
        public LoaiSach(string maloai, string loai)
        {
            this.maloai = maloai;
            this.loai = loai;
        }

        public void set_maloaisach(string maloai)
        {
            this.maloai = maloai;
        }

        public void set_loaisach(string loai)
        {
            this.loai = loai;
        }

        public bool taomoi()        
        {
            Truyxuatdulieu txdl=new Truyxuatdulieu();
            if (txdl.thucthitruyvan("insert into loaisach values('" + maloai + "',N'" + loai + "')") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else 
            {
                KetNoi.closeconnect();
                return false;
            }
        }

        public bool update()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("update loaisach set loai=N'" + loai + "' where maloai='" + maloai + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else 
            {
                KetNoi.closeconnect();
                return false;
            }
        }

        public bool xoa()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan("delete from loaisach where maloai='" + maloai + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else
            {
                KetNoi.closeconnect();
                return false;
            }
        }
    }
}
